/*
    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

*/

#ifndef DRAW_BOX_H
#define DRAW_BOX_H

namespace object{
    class Vertex;
};
namespace draw {

  class Ray;
  
class Box
{
  public:
    Box(){;}
    ~Box(){;}
    
    inline void setXmin(float val){m_xmin = val;}
    inline void setYmin(float val){m_ymin = val;}
    inline void setZmin(float val){m_zmin = val;}
    
    inline void setXmax(float val){m_xmax = val;}
    inline void setYmax(float val){m_ymax = val;}
    inline void setZmax(float val){m_zmax = val;}
    
    inline float getXmin(){return m_xmin;}
    inline float getYmin(){return m_ymin;}
    inline float getZmin(){return m_zmin;}
    
    inline float getXmax(){return m_xmax;}
    inline float getYmax(){return m_ymax;}
    inline float getZmax(){return m_zmax;}
    
    inline void setValues(float xmin, float ymin, float zmin,
                          float xmax, float ymax, float zmax)
    {
      m_xmin = xmin;
      m_ymin = ymin;
      m_zmin = zmin;
      
      m_xmax = xmax;
      m_ymax = ymax;
      m_zmax = zmax;
    }
    
    Box* combine(Box *temp);
    
    bool hit(draw::Ray * ray); 
    bool hit(draw::Ray * ray, bool dummy);
    void prepare(object::Vertex * valOrigin);
    
  private:
    float m_xmin;
    float m_ymin;
    float m_zmin;
    
    float m_xmax;
    float m_ymax;
    float m_zmax;
    
    // helpvars for hit function
    float txmin;
    float txmax;
    float reciproc;
    float tymin;
    float tymax;
    float tzmin;
    float tzmax;
    
    float xminREC;
    float xmaxREC;
    float yminREC;
    float ymaxREC;
    float zminREC;
    float zmaxREC;
};

}

#endif // DRAW_BOX_H
